package com.ming.springcloud.student.service;

import com.ming.springcloud.student.dao.IBookDao;
import com.ming.springcloud.student.pojo.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;

@Service("bookService")
public class BookServiceImpl implements IBookService{
    @Resource
    @Autowired
    private IBookDao bookDao;
    @Override
    public Page<Book> findAllServers(Pageable pageable) {
        return bookDao.findAll(pageable);
    }

    @Override
    public void delete(Integer id) {
        bookDao.deleteById(id);
    }

    @Override
    public void save(Book Book) {
        bookDao.save(Book);
    }

    @Override
    public Optional<Book> findUserById(Integer id) {
        return bookDao.findById(id);
    }

    @Override
    public void edit(Book Book) {
        bookDao.save(Book);
    }

    @Override
    public List<Book> findBybookNameLike(String name) {
        return bookDao.findBybookNameLike(name);
    }

    @Override
    public List<Book> findAll() {
        return bookDao.findAll();
    }
}
